package org.example.learn.javaagent.apply_demo.test;

import java.util.Random;

// 需配置vm options: -javaagent:E:\open-sourcing\learn-bytecode\learn-javaagent\target\learn-javaagent-1.0-SNAPSHOT.jar=testargs
public class ApplyRun {

    public static void main(String[] args) {

        // 线程1
        new Thread(new Runnable() {
            @Override
            public void run() {
                new ApplyRun().test1();
            }
        }).start();

        // 线程2
        new Thread(() -> {
           new ApplyRun().test2("李四");
           new TDate().test();
        }).start();

    }

    public void test1(){
        System.out.println("Method Test 1");
        try {
            Thread.sleep(new Random().nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("调用test2()");
        test2("张三");
    }

    public void test2(String name) {
        System.out.println("Method Test 2");
        try {
            Thread.sleep(new Random().nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("name： " + name);
        System.out.println("调用test3()");
        test3(1234);
    }

    public void test3(int val) {
        System.out.println("Method Test 3");
        try {
            Thread.sleep(new Random().nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("val: " + val);
    }
}
